﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SearchWin.aspx.cs" Inherits="TimKen.Web.Admin.SearchWin"
    MasterPageFile="~/Admin/PopupPage.master" %>

<asp:Content ID="content1" ContentPlaceHolderID="ContentMain" runat="server">
 
    <script language="javascript" type="text/javascript">
        function getData() {
            var  isMultiSelect = "<%=MoreSelect%>";
            var re = new Array();
            var gridView=document.getElementById("<%=GridView1.ClientID%>");
            if(gridView)
            {
            //根据当前时候允许多选择返回不同的数组对象
            if(isMultiSelect!="False")
            {
                for(var i=1;i<gridView.firstChild.childNodes.length;i++)
                {
                    if(gridView.firstChild.childNodes[i].firstChild.firstChild.checked)
                    { 
                        var values=new Array();
                        for(var j=1;j<gridView.firstChild.childNodes[i].childNodes.length;j++)
                        {
                            values[j-1]=gridView.firstChild.childNodes[i].childNodes[j].innerText;
                        }
                        re[re.length]=values;
                    }
                }
            }
            else//单选
            {
             for(var i=1;i<gridView.firstChild.childNodes.length;i++)
                {
                   if(gridView.firstChild.childNodes[i].firstChild.firstChild.checked)
                    {
                       for(var j=1;j<gridView.firstChild.childNodes[i].childNodes.length;j++)
                        {
                            re[j-1]=gridView.firstChild.childNodes[i].childNodes[j].innerText;
                        }   
                        break;
                    }
                }
            }
          }
            window.returnValue = re;
            window.close();
        }
        function singleCheck(obj)
        {
          var isMultiSelect ="<%=MoreSelect%>";
          var gridView=document.getElementById("<%=GridView1.ClientID%>");
         var currentIndex=0;
          if(isMultiSelect=="False")//单选的话就要将其他已经选择的选重新设置为非选择
          {
          for(var i=1;i<gridView.firstChild.childNodes.length;i++)
          {
             if(gridView.firstChild.childNodes[i].firstChild.firstChild.checked)
             {
             if(gridView.firstChild.childNodes[i].firstChild.firstChild===obj) 
                continue;
             else
               gridView.firstChild.childNodes[i].firstChild.firstChild.checked=false;
                
            }
          }
         }
          
        }
        
        
    </script>

    <asp:Label ID="Prompt1" runat="server"></asp:Label>
    <div class="list-div">
        <input type="button" value="确定" id="btnOK" onclick="getData();" class="button" />
        
        
        <TABLE id="tbSearch" cellSpacing="0" borderColorDark="aliceblue" cellPadding="0" border="1"  runat="server">
       
            
		 </TABLE>
						
				<INPUT id="transValue" style="Z-INDEX: 102; LEFT: 8px; POSITION: absolute; TOP: 64px" type="hidden"
				name="Hidden1"  value="UserAccount">
				
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" CssClass="grid">
            <Columns>
                <asp:TemplateField HeaderText="选择">
                    <ItemTemplate>
                        <input type="checkbox" id="ckSelect" name="ckSelect" onclick="singleCheck(this);" />
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>
    </div>
    <div class="pager-div">
        <ux:AspNetPager ID="AspNetPager1" runat="server" Width="100%" ShowPageIndexBox="Always"
            PageSize="10" HorizontalAlign="right" EnableTheming="true" AlwaysShow="true"
            PageIndexBoxType="DropDownList" OnPageChanged="AspNetPager1_PageChanged" ImagePath="/images/"
            NavigationButtonType="Image" ButtonImageNameExtension="n" CpiButtonImageNameExtension="r"
            PagingButtonType="Image">
        </ux:AspNetPager>
    </div>
</asp:Content>
